fix/batches: prevent workspace path injection - #1372
Merged
cbrnrd merged 4 commits intoSep 9, 2026
Merged
Conversation
cbrnrd
marked this pull request as ready for review
September 8, 2026 15:20
DaedalusG
approved these changes
Sep 8, 2026
Contributor
|
I believe #1373 fixes the same issue but its a better fix |
Contributor
Author
|
@DaedalusG there were some other places that needed a fix, #1373 does fix the original issue but now there's more that PR doesn't cover. |
BolajiOlajide
approved these changes
Sep 9, 2026
…e-a-server-supplied-workspacepath-is
cbrnrd
enabled auto-merge (squash)
September 9, 2026 18:23
cbrnrd
deleted the
carterbrainerd-vuln-143-src-batch-volume-mode-a-server-supplied-workspacepath-is
branch
September 9, 2026 18:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In volume workspace mode,
src batchput a workspace file name directly into a Docker mount specification and a shell command. Workspace paths can come from directory names in repository content. A crafted directory name could therefore change the mount specification and run shell commands during workspace setup.The same server-provided data was also trusted in two related places:
..could copy.gitignoreor.gitattributesoutside the workspace and change permissions on a host directory.This fixes VULN-143 and the related issues identified while verifying the fix.
Solution
Use fixed, generated paths for temporary Docker mounts and pass workspace destination names as shell arguments instead of adding them to the shell command.
Reject additional workspace file paths that resolve outside the workspace in both bind and volume modes.
Move Docker bind mount construction into a shared helper that validates every source and target before building the mount specification. Use that helper for all bind mounts in the batches code.
Verification Evidence
go test ./internal/batches/...successfully.